const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,
  
  // 开发服务器配置
  devServer: {
    port: 8080,
    host: 'localhost',
    // 禁用热重载的socket连接错误提示
    client: {
      overlay: {
        errors: false,  // 关闭错误遮罩层
        warnings: false,
        runtimeErrors: false,
      },
      logging: 'none',  // 完全关闭客户端日志
      webSocketURL: 'auto://0.0.0.0:0/ws'  // 修复WebSocket连接问题
    },
    // 减少不必要的日志输出
    compress: false,
    hot: false,  // 关闭热重载
    liveReload: false,
    allowedHosts: 'all',  // 允许所有主机访问
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
      'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
    }
  },
  
  // 配置webpack
  configureWebpack: {
    // 减少chunk大小和数量
    optimization: {
      minimize: false,  // 开发环境不压缩
      splitChunks: {
        chunks: 'all',
        cacheGroups: {
          vendors: {
            test: /[\\/]node_modules[\\/]/,
            name: 'vendors',
            chunks: 'all',
            maxSize: 500000,  // 限制chunk大小
          }
        }
      }
    },
    // 忽略一些可能导致错误的模块
    resolve: {
      fallback: {
        "path": false,
        "fs": false,
        "crypto": false
      }
    }
  },
  
  // 关闭性能提示
  performance: {
    hints: false,
    maxAssetSize: 500000,
    maxEntrypointSize: 500000
  },
  
  // 关闭source map以减少错误
  productionSourceMap: false,
  
  // CSS相关配置
  css: {
    extract: false,  // 开发环境不提取CSS
    sourceMap: false
  }
}) 